
package com.unitins.cliente;

import com.unitins.servidor.Clientes;
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.GridLayout;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.ArrayList;
import java.util.Scanner;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author CristhiannRodrigues
 */
public class Cliente extends JFrame{
    
    JTextField v1 = null;
    JTextField v2 = null;
    
    JButton Bsomar = null;
    JButton Bsub = null;
    JButton Bdivisao = null;
    JButton Bmultiplicacao = null;
    public Container container = null;
    public Container containerB = null;
    
    Socket socket = null;
    PrintWriter escrever = null;
    String nome = null;
    Scanner leitor = null;
    
    
    public int i=0;
    Clientes nomeC = new Clientes();
    
    private void ConfiguraRede(){
        try{
            socket = new Socket("172.16.90.250", 3030);
            escrever = new PrintWriter(socket.getOutputStream());
            leitor = new Scanner(socket.getInputStream());
            //new Thread(new EscutaServidor()).start();
        }catch(Exception e){
        }
    }
    
    public Cliente(String nome){
        String nome1 = new String();
        nome1 = nome;
        v1 = new JTextField();
        v2 = new JTextField();
        
        Bsomar = new JButton("SOMAR");
        Bsub = new JButton("SUBTRACAO");
        Bdivisao = new JButton("DIVISAO");
        Bmultiplicacao = new JButton("MULTIPLICACAO");
        
        container = new JPanel();
        containerB = new JPanel();
        container.setLayout(new GridLayout(1,2));
        container.add(BorderLayout.NORTH, v1);
        container.add(BorderLayout.NORTH, v2);
        containerB.add(BorderLayout.EAST, Bsomar);
        containerB.add(BorderLayout.EAST, Bsub);
        containerB.add(BorderLayout.EAST, Bdivisao);
        containerB.add(BorderLayout.EAST, Bmultiplicacao);
        
        
        getContentPane().add(BorderLayout.CENTER, container);
        getContentPane().add(BorderLayout.SOUTH, containerB);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setSize(500, 300);
        setVisible(true);
        
        
        
        nomeC.setNomeCliente(nome);
        System.out.println(nome);
        
        ConfiguraRede();
    }
        
    
    public static void main(String args[]){
        new Cliente("Manolo 1");
        new Cliente("Manolo 2");
        new Cliente("Manolo 3");
    }
}
